<template>
    <div class="dialogPop">
      <el-dialog :visible.sync="updataData.dialogUpdata" :before-close="handleClose" size="tiny" title="修改视角">
        <el-form :model="updataData" :rules="rules" ref="updataData" label-width="90px">
          <el-row :gutter="20">
            <el-col :span="22">
              <el-form-item label="视角名称:" prop="sAngleView">
                   <el-popover placement="top-start" trigger="focus"
                                content="字符长度不大于4个">
                      <el-input v-model="updataData.sAngleView" slot="reference" :maxlength="4"  placeholder="请输入摄像机视角名称"></el-input>
                   </el-popover>
              </el-form-item>
            </el-col>
          </el-row>
        </el-form>
        <div slot="footer" class="dialog-footer">
          <p class="btn">
            <el-button @click="resetForm('updataData')">取 消</el-button>
            <el-button type="primary" @click="updataBtn('updataData')" :loading="loadingBtn">确 认</el-button>
          </p>
        </div>
      </el-dialog>
    </div>
</template>
<script>
import { updateAngleView} from 'api/deviceManagement';
export default {
    props: {
        updataData: {
            default() {
                return {
                    dialogUpdata: false // 默认不显示
                }
            },
            required: true
        }
    },
    data() {
        return {
            loadingBtn: false,
            rules: {
                sAngleView: [
                     { required: true, message: '请输入视角名称', trigger: 'blur' },
                     { pattern: /^[^\s]+$/, message: '请勿输入空格', trigger: 'blur' }
                ]
            }
        }
    },
    methods: {
    // 确定按钮
        updataBtn(addTeaPop) {
            this.$refs[addTeaPop].validate((valid) => {
                if (valid) {// 验证通过
                    this.loadingBtn=true;
                    let pId=this.updataData.pId;
                    let sAngleView=this.updataData.sAngleView;
                    updateAngleView(pId, sAngleView).then(res => {
                        if (res.data.status==200) {
                            this.loadingBtn=false;
                            this.$message({
                                type: 'success',
                                message: '修改成功!'
                            });
                            this.$emit('searchList');// 更新列表
                            this.handleClose();
                        }
                    })
                } else {
                    return false;
                }
            });
        },
        handleClose() {
            this.delDialogAddTea();
        },
    // 取消按钮 
        resetForm(dataForm) {
            this.$refs[dataForm].resetFields();
            this.delDialogAddTea();
        },
    // 还原弹窗信息
        delDialogAddTea() {
            this.updataData.dialogUpdata = false;
            this.updataData.eyeName = '';
        }
    }
}
</script>



